﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using System.Web;
using Microsoft.AspNetCore.Mvc;
using ArchivesAdmin.Util;
using ArchivesAdmin.Util.Model;
using ArchivesAdmin.Entity;
using ArchivesAdmin.Model;
using ArchivesAdmin.Admin.Web.Controllers;
using ArchivesAdmin.Entity.DataManage;
using ArchivesAdmin.Business.DataManage;
using ArchivesAdmin.Model.Param.DataManage;

namespace ArchivesAdmin.Admin.Web.Areas.DataManage.Controllers
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2021-06-14 17:39
    /// 描 述：控制器类
    /// </summary>
    [Area("DataManage")]
    public class AjbxxbController :  BaseController
    {
        private AjbxxbBLL ajbxxbBLL = new AjbxxbBLL();

        #region 视图功能
        [AuthorizeFilter("data:ajbxxb:view")]
        public ActionResult AjbxxbIndex()
        {
            return View();
        }

        public ActionResult AjbxxbForm()
        {
            return View();
        }
        #endregion

        #region 获取数据
        [HttpGet]
        [AuthorizeFilter("data:ajbxxb:search")]
        public async Task<ActionResult> GetListJson(AjbxxbListParam param)
        {
            TData<List<AjbxxbEntity>> obj = await ajbxxbBLL.GetList(param);
            return Json(obj);
        }

        [HttpGet]
        [AuthorizeFilter("data:ajbxxb:search")]
        public async Task<ActionResult> GetPageListJson(AjbxxbListParam param, Pagination pagination)
        {
            TData<List<AjbxxbEntity>> obj = await ajbxxbBLL.GetPageList(param, pagination);
            return Json(obj);
        }

        [HttpGet]
        public async Task<ActionResult> GetFormJson(long id)
        {
            TData<AjbxxbEntity> obj = await ajbxxbBLL.GetEntity(id);
            return Json(obj);
        }
        #endregion

        #region 提交数据
        [HttpPost]
        [AuthorizeFilter("data:ajbxxb:add,data:ajbxxb:edit")]
        public async Task<ActionResult> SaveFormJson(AjbxxbEntity entity)
        {
            TData<string> obj = await ajbxxbBLL.SaveForm(entity);
            return Json(obj);
        }

        [HttpPost]
        [AuthorizeFilter("data:ajbxxb:delete")]
        public async Task<ActionResult> DeleteFormJson(string ids)
        {
            TData obj = await ajbxxbBLL.DeleteForm(ids);
            return Json(obj);
        }
        #endregion
    }
}
